package com.k2.gulimall.member.controller;

import com.k2.common.utils.R;
import com.k2.gulimall.member.service.MemberDetailsService;
import com.k2.gulimall.member.vo.MemberDetailsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("member/Details")
public class MemberDetailsController {

    @Autowired
    MemberDetailsService memberDetailsService;

    /**
     * 通过用户id获取用户的详细信息 以便更改用户信息（成长值-积分）
     * @param id
     * @return
     */
    @GetMapping("/getMemberDetails/{id}")
    public R getMemberDetails(@PathVariable("id") Long id){
        MemberDetailsVo memberDetailsVo = memberDetailsService.getMemberDetails(id);
        if(memberDetailsVo!=null){
            return R.ok().put("data",memberDetailsVo).put("code",0);
        }else{
            return R.error().put("msg","网络连接超时").put("code",1);
        }
    }

}
